package com.core.controller;

import com.core.common.CommentResult;
import com.core.service.MockService;
import com.core.vo.MockVo;
import com.core.vo.Screen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * create by yongli on 2021-09-16 19:33
 */
@RestController
// 该路径的所有路径和子路径
@RequestMapping("mock/**")
public class MockController {

    @Autowired
    MockService mockService;

    @PostMapping
    public int save(@RequestBody MockVo mockVo) {
        return mockService.insert(mockVo);
    }

    // ReuquestBody不能用于get方法
    @GetMapping
    public String query(@RequestParam String param) {
        return mockService.selectByParam(param).getResult();
    }

    @RequestMapping("test")
    public CommentResult<Screen> test() {
        CommentResult<Screen> ret = new CommentResult<>();
        ret.setData(new Screen("3223"));
        return ret;
    }
}


